public class Test {
}
class Solution {
    public int[] reversePrint(ListNode head) {
        ListNode cur = head;
        ListNode prev = null;
        int count = 0;
        while(cur != null){
            ListNode curN = cur.next;
            cur.next = prev;
            prev = cur;
            cur = curN;
            count++;
        }
        int[] arr = new int[count];
        int k = 0;
        while(prev != null){
            arr[k++] = prev.val;
            prev = prev.next;
        }
        return arr;
    }
}
